<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<p>p</p>
<div>div</div>
<span>span</span>
<p>p</p>
<div>div</div>
</body>
<script>
    function select(selector){
        var obj=document.querySelectorAll(selector);
        obj.Each=function(callback){
            each(this,callback)
        }
        return obj;
    }

    function each(arr,callback){
        for(var i=0;i<arr.length;i++){
            callback(arr[i],i)
        }
    }
    select("div,p").Each(function(v){
        v.style.border="1px solid red";
    });
</script>
</html>